import request from "@/utils/request";

//申请回收API
const RECYCLE_REQUEST_BASE_URL = "/api/v1/recycle-request";

const RecycleRequetAPI = {
  /**
   * 用户发起申请回收
   */
  initUserRecycleRequest(data: any) {
    return request({
      url: `${RECYCLE_REQUEST_BASE_URL}/user-init`,
      method: "post",
      data: data,
    });
  },
  /**
   *
   *修改申请
   */
  updateUserRecycleRequest(data: any) {
    return request({
      url: `${RECYCLE_REQUEST_BASE_URL}/user-update`,
      method: "post",
      data: data,
    });
  },
  /**
   * 查询回写表单
   */
  getRecycleRequestForm(id?: number) {
    return request({
      url: `${RECYCLE_REQUEST_BASE_URL}/${id}/form`,
    });
  },
  /**
   * (用户)查询分页数据
   */
  getRecycleRequestPage(data?: RecycleQueryParams) {
    return request({
      url: `${RECYCLE_REQUEST_BASE_URL}/page`,
      method: "post",
      data: data,
    });
  },

  /**
   * 用户发起取消申请
   */
  applyCancelRequest(data: any) {
    return request({
      url: `${RECYCLE_REQUEST_BASE_URL}/user-cancel`,
      method: "post",
      data: data,
    });
  },
  /**
   * 获取所有垃圾类型
   */
  getAllWasteTypes() {
    return request({
      url: `${RECYCLE_REQUEST_BASE_URL}/all-waste-type`,
      method: "get",
    });
  },

  /**
   * 获取所有垃圾类型
   */
  getEmissionStats(params: any) {
    return request({
      url: `${RECYCLE_REQUEST_BASE_URL}/emission-stats`,
      method: "get",
      params: params,
    });
  },
};

//  首先定义垃圾类型接口
export interface WasteItem {
  id: string;
  typeId: string;
  fileUrl: string;
  weight: number | undefined;
  actualPrice: number;
}

export interface RecycleQueryParams {
  username?: string;
  orgName?: string;
  status?: [];

  minExpectReturn?: number;
  maxExpectReturn?: number;

  recycleTimeStart?: Date;
  recycleTimeEnd?: Date;

  createTimeStart?: string;
  createTimeEnd?: string;

  pageNum?: number;
  pageSize?: number;
}

export default RecycleRequetAPI;
